<template>
  <div id="app" @click="clicked">
     <keep-alive>
         <router-view/>
     </keep-alive>
  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
  	return {
			lastTime: new Date().getTime(),  //最后点击时间
			currentTime: new Date().getTime(),  //当前时间
			validTime : 60 * 60 * 1000,    //允许时间 
			timer :null
  	}
  },
  methods:{
  	clicked(){
  		this.lastTime = new Date().getTime()
  	},
  	isTime(){
  		 this.currentTime = new Date().getTime()
	  		if( this.currentTime - this.lastTime> this.validTime){
	  			 if(sessionStorage.token){
	  			 	   this.$router.push({ path: '/login' })
	  			 }
	  		}
  	}
  },
  mounted(){
 	   this.timer = window.setInterval(this.isTime,1000)
  }
}
</script>

<style>
	#app{
		width:100%;
		height:100%;
	}
</style>
